package it.traveldream.entities;

import it.traveldream.dto.ProductDTO;

import java.io.Serializable;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Entity implementation class for Entity: BookedProduct
 *
 */
@Entity
@Table(name="BookedProduct")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPEID", discriminatorType=DiscriminatorType.INTEGER)
public abstract class BookedProduct implements Serializable {

	@Id
	@GeneratedValue
	protected Long bookedProductId;
	
	@ManyToOne(optional = false)
	@JoinColumn(name = "PRODUCTID", referencedColumnName = "PRODUCTID", nullable = false)
	protected Product product;
	
	@ManyToOne(optional = false)
    @JoinColumn(name = "TYPEID", referencedColumnName = "PRODUCTTYPEID", nullable = false)
	protected ProductType type;
	
	private static final long serialVersionUID = 1L;

	public BookedProduct() {
		super();
	}

	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}   
	
	public abstract ProductDTO toDTO();
}
